//
//  SpreadOrderListCellModel.m
//  EnvironmentalProtection
//
//  Created by HCreater on 2018/12/24.
//  Copyright © 2018年 HCreater. All rights reserved.
//

#import "SpreadOrderListCellModel.h"

#import "SpreadOrderListData.h"

@interface SpreadOrderListCellModel ()

@property (nonatomic, readwrite, copy) NSString* name;
@property (nonatomic, readwrite, copy) NSString* orderTime;
@property (nonatomic, readwrite, copy) NSString* orderNum;
@property (nonatomic, readwrite, copy) NSString* payTypeName;

@end

@implementation SpreadOrderListCellModel

- (instancetype)initWithData:(id)data cellHeight:(CGFloat)cellHeight
{
    self = [super init];
    if (self)
    {
        _data = data;
        
        /// cellHeight+2（2容错）
        _cellHeight = MHUIScaleValue(cellHeight)+2;
        
        @weakify(self);
        SpreadOrderListData* spreadOrderListData = data;
        
        NSString* name = @"";
        if (spreadOrderListData.area.count > 0)
        {
            AreaInfoData* firstAreaInfoData = spreadOrderListData.area[0];
            
            name = HCStrFormat(@"%@等%d个城市", firstAreaInfoData.areaName, (int)spreadOrderListData.area.count);
        }
        self.name = name;
        self.orderTime = HCStrFormat(@"下单时间：%@", spreadOrderListData.addTime);
        self.orderNum = HCStrFormat(@"单号：%@", spreadOrderListData.spreadSN);
        
        NSInteger status = [spreadOrderListData.status integerValue];
        self.payTypeName = status == 1 ? @"待付款" : (status == 2 ? @"已付款" : @"退款"); //1待付款2已付款3退款
    }
    
    return self;
}

@end
